package com.example.service;

import com.example.entity.BooksCategory;
import com.example.entity.Checkpoint;
import com.example.mapper.BooksCategoryMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
书籍分类业务处理
 */
@Service
public class BooksCategoryService {

    @Resource
    private BooksCategoryMapper booksCategoryMapper;

    public void add(BooksCategory booksCategory) {
        booksCategoryMapper.insert(booksCategory);
    }

    public void deleteById(Integer id) {
        booksCategoryMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(BooksCategory booksCategory) {
        booksCategoryMapper.updateById(booksCategory);
    }

    public BooksCategory selectById(Integer id) {
        return booksCategoryMapper.selectById(id);
    }

    public List<BooksCategory> selectAll(BooksCategory booksCategory) {
        return booksCategoryMapper.selectAll(booksCategory);
    }

    public PageInfo<BooksCategory> selectPage(BooksCategory booksCategory, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<BooksCategory> booksCategoryList = booksCategoryMapper.selectAll(booksCategory);
        return PageInfo.of(booksCategoryList);
    }
}
